<?php

//发送短信类
class SmsHelper extends HttpRequestHelper {

    public $mobilephone;
    public $matter;
    public $account;
    public $pwd;
    public $url;
    public $shijian;
    public $sign = '中企聚易';

    function __construct() {
        $this->shijian = date('ymdHis');
    }

    //发送短信
    public function send() {
        return file_get_contents($this->url);
    }

    public function QueryBalance() {
        return $this->send();
    }

    public function validate($number = true, $len = 6) {
        $code = rand(100000, 999999);
        if ($number == FALSE) {
            $code='';
            $charlist = 'qwertyuiopasdfghjklzxcvbnm1234567890';
            $charlen = count($charlist);
            for ($i = 0; $i < $len; $i++) {
                $code.= substr($charlist, rand(0, $charlen), 1);
            }
        }
        $this->matter = '您的短信验证码是：' . $code;
        $this->send();
        return $code;
//        echo md5($code);
    }

}

//凌凯
class InoLinkCom extends SmsHelper {

    function __construct() {
        $this->account = 'TCLKJ02825';
        $this->pwd = '15810208908';
    }

    public function send() {
        $this->url = "http://inolink.com/ws/BatchSend.aspx?CorpID=" . $this->account . "&Pwd=" . $this->pwd . "&Mobile=" . $this->mobilephone . "&Content=" . iconv('UTF-8', 'gb2312//IGNORE', $this->matter . '【' . $this->sign . '】') . "&SendTime=";
        return parent::send();
    }

    public function QueryBalance() {
        $this->url = "http://inolink.com/WS/SelSum.aspx?CorpID=" . $this->account . "&Pwd=" . $this->pwd;
        return parent::QueryBalance();
    }

}

//助通
class ZtSms extends SmsHelper {

    public $productid = '676767';
    public $xh;

    function __construct() {
        $this->account = 'zhongqi';
        $this->pwd = md5(md5('P9gTkbLQ') . $this->shijian);
    }

    public function send() {
        $this->url = "http://www.ztsms.cn/sendSms.do?username=" . $this->account . "&tkey=" . $this->shijian . "&password=" . $this->pwd . "&mobile=" . $this->mobilephone . "&content=" . urlencode('【' . $this->sign . '】' . $this->matter) . "&dstime=" . "&productid=" . $this->productid . "&xh=" . $this->xh;
        return parent::send();
    }

    public function QueryBalance() {
        $this->url = "http://inolink.com/ws/Get.aspx?CorpID=" . $this->account . "&Pwd=" . $this->pwd;
        return parent::QueryBalance();
    }

}

?>
